package offer;

/*
* P59 面试题7：用两个栈实现队列
* */

import java.util.Stack;

public class TwoStackAsQueue<T> {
    private Stack<T> stack1 = new Stack<>();
    private Stack<T> stack2 = new Stack<>();

    public T deleteHead(){
        if(stack2.isEmpty()){
            while(!stack1.isEmpty()){
                stack2.push(stack1.pop());
            }
        }
        return stack2.pop();
    }

    public void appendTail(T v){
        if(v != null){
            stack1.push(v);
        }
    }
}

